import { BaseApi } from '/@/api-services/apis/baseApi';
import { SysRole, RoleUpdateInput, RoleAddInput,RoleSelectorOutput,RoleMenusInput, RoleUsersInput, RoleResourceInput,RoleResourceOutput,UserSimpleOutput } from '/@/api-services/models/system'
import { BaseIdInput } from '/@/api-services/models/base-id-input'
/**
 * 菜单管理Api 
 */
class SysRoleApi extends BaseApi<SysRole, RoleAddInput, RoleUpdateInput> {
    //角色选择
    roleSelector=async(data:object)=>{
        return this.normalGet<Array<RoleSelectorOutput>>(`/selector`,data)
    }
    //获取资源
    getResource=async(data:BaseIdInput)=>{
        return this.normalGet<Array<String>>(`/resource`,data)
    }
    //获取角色已分配资源
    getOwnResource=async(data:BaseIdInput)=>{
        return this.normalGet<Array<RoleResourceOutput>>(`/ownResource`,data)
    }
    //获取角色已分配菜单
    getOwnMenu=async(data:BaseIdInput)=>{
        return this.normalGet<Array<Number>>(`/ownMenu`,data)
    }
    //获取角色已授权用户
    getOwnUser=async(data:BaseIdInput)=>{
        return this.normalGet<Array<UserSimpleOutput>>(`/ownUser`,data)
    }

    //分配菜单
    grantRoleMenus=async(data:RoleMenusInput)=>{
        this.normalPost(`/grantRoleMenus`,data)
    }
    //授权用户
    grantRoleUsers=async(data:RoleUsersInput)=>{
        this.normalPost(`/grantRoleUsers`,data)
    }
    //分配资源
    grantRoleResource=async(data:RoleResourceInput)=>{
        this.normalPost(`/grantRoleResource`,data)
    }
}

export default new SysRoleApi('/system/role');